package org.smartcti.freeswitch.util.internal;


import org.apache.commons.beanutils.Converter;
import org.smartcti.freeswitch.inbound.event.ChannelState;

public class CustomerChannelStateConverter implements Converter {

	@SuppressWarnings("unchecked")
	public Object convert(Class type, Object value) {
		 if (type.equals(ChannelState.class) && value instanceof String ) {
			 String strValue = (String)value;
			 if(strValue!=null && strValue.length()>3){
				 strValue = strValue.substring(3);
				 return ChannelState.valueOf(strValue);
			 }else{
				 return null;
			 }
      }
		return null;
	}

}
